package com.gec.teams.wechat.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * 功能：
 * 作者：YumTea
 * 日期：2024/6/22 14:32
 */
@Component
//多例的bean
@Scope("prototype")
public class EmailTask implements Serializable {
    @Autowired
    private JavaMailSender javaMailSender;
    @Value("${teams.email.system}")
//    这个应该是发送的邮箱吧?
    private String mailBox;

    @Value("${teams.email.boss}")
    private String toEmail;

    @Async
    public void sendAsync(SimpleMailMessage message){
//        message.setFrom(mailBox);
//        message.setTo(toEmail);
        javaMailSender.send(message);
    }
}
